package com.sheep.pattern.chain.array;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author wangze
 * @date 2021-03-12 10:24.
 **/
public class ArrayChain {
	private List<HandleService> handleServices = new ArrayList<>();

	public void addService(HandleService... hss) {
		this.handleServices.addAll(Arrays.asList(hss));
	}

	public void  execute(){
		for(HandleService handleService: handleServices){
			if(!handleService.handle()){
				break;
			}
		}
		System.out.println("执行完毕");
	}

	public static void main(String[] args) {

		HandleService serviceA=new HandleA();
		HandleService serviceB=new HandleB();

		ArrayChain arrayChain=new ArrayChain();

		arrayChain.addService(serviceA,serviceB);


		arrayChain.execute();

	}

}
